package app.model {

	/**
	 * @author Rendall
	 */
	public class Time {
		public static const SECOND : uint = 1000;
		public static const MINUTE : uint = 60 * SECOND;
		public static const HOUR : uint = 60 * MINUTE;
		public static const DAY : uint = 24 * HOUR;
		public static const WEEK : uint = 7 * DAY;
		//public static const YEAR : uint = 365 * DAY; // update 365.25 * DAY
		
		public static const SUNDAY:uint = 0;
		public static const MONDAY:uint = 1;		public static const TUESDAY:uint = 2;		public static const WEDNESDAY:uint = 3;		public static const THURSDAY:uint = 4;		public static const FRIDAY:uint = 5;		public static const SATURDAY:uint = 6;		
		public static const JANUARY:uint = 0;		public static const FEBRUARY:uint = 1;		public static const MARCH:uint = 2;		public static const APRIL:uint = 3;		public static const MAY:uint = 4;		public static const JUNE:uint = 5;		public static const JULY:uint = 6;		public static const AUGUST:uint = 7;		public static const SEPTEMBER:uint = 8;		public static const OCTOBER:uint = 9;		public static const NOVEMBER:uint = 10;		public static const DECEMBER:uint = 11;		


		public static function now():uint{			
			return new Date().valueOf();
		}
		
		public static function since(then:uint):uint{
			return now()-then;			
		}
		
		/**
		 * Time Static Constructor
		 */
		public function Time() {
			throw new Error("Time is a static class and cannot be instantiated.");
		}
		
		public static function getWeekday(value:uint, isShort:Boolean = false):String{
			var returnVal:String;
			
			switch (value) {
			        case SUNDAY: returnVal = "Sunday"; break;			        case MONDAY: returnVal = "Monday"; break;			        case TUESDAY: returnVal = "Tuesday"; break;			        case WEDNESDAY: returnVal = "Wednesday"; break;			        case THURSDAY: returnVal = "Thursday"; break;			        case FRIDAY: returnVal = "Friday"; break;			        case SATURDAY: returnVal = "Saturday"; break;
			}
			
			return isShort? returnVal.slice(0,3):returnVal;	
		}
		
		public static function getMonth(value:uint, isShort:Boolean = false):String{
			var returnVal:String;
			
			switch (value) {
			        case JANUARY: returnVal = "January"; break;			        case FEBRUARY: returnVal = "February"; break;			        case MARCH: returnVal = "March"; break;			        case APRIL: returnVal = "April"; break;			        case MAY: returnVal = "May"; break;			        case JUNE: returnVal = "June"; break;			        case JULY: returnVal = "July"; break;			        case AUGUST: returnVal = "August"; break;			        case SEPTEMBER: returnVal = "September"; break;			        case OCTOBER: returnVal = "October"; break;			        case NOVEMBER: returnVal = "November"; break;			        case DECEMBER: returnVal = "December"; break;			
			}			
			
			return isShort? returnVal.slice(0,3):returnVal;
		}
	}
}
